﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Enterprise.Modules;

namespace Enterprise.ClientWeb.Module
{
    public partial class ModuleController : ModuleAdminControls, ModuleAdmin
    {
        private string _RegionID;
        private ModuleBase _module;
        private string _ModuleID;
       

        protected void Page_Load(object sender, EventArgs e)
        {
            if (_module.Module.Active)
                editButton.ImageUrl = "~/Images/Controls/editDeactivated.png";
        }

        protected void Page_Init()
        {
            moduleView.SetActiveView(adminView);
        }

        public ModuleBase Module
        {
            set { this._module=value; }
        }

        public string RegionID
        {
            get{return _RegionID;}
            set{this._RegionID=value;}
        }

        public string ModuleID
        {
            get { return _ModuleID; }
            set { _ModuleID = value; }
        }

        protected void MoveModuleUp(object sender, EventArgs e)
        {
            base.Move(Direction.UP,RegionID,Request["PageID"], ModuleID);
        }

        protected void MoveModuleDown(object sender, EventArgs e)
        {
            base.Move(Direction.DOWN, RegionID, Request["PageID"], ModuleID);
        }

        protected void DeleteModule(object sender, EventArgs e)
        {
            _module.Module.Delete();
            Response.Redirect(Request.RawUrl);
        }

        protected void ToggleArea(object sender, EventArgs e)
        {
            if (ModuleArea.Visible ==false)
            {
                ModuleArea.Visible = true;
                _module.ViewMode = ViewMode.Edit;
            }
            else
            {
                ModuleArea.Visible=false;
                _module.ViewMode = ViewMode.Readonly;
            }
        }

        protected void ToggleMode(object sender, EventArgs e)
        {
            if (_module.ViewMode == ViewMode.Edit)
            {
                _module.ViewMode = ViewMode.Readonly;
            }
            else
            {
                _module.ViewMode = ViewMode.Edit;
            }
        }

    }
}